<include file="Public:top" /> 
{// 引入标签库 }
<tagLib name="html" />
<style>
input{margin-bottom:10p;}
#tb1 tr{ height:35px;}
</style>
<script>
var editor;
</script>
<div id="main" class="" >
<div class="content">
<div class="title">{$vo.wymc}教育物业信息管理  [ <a href="__URL__">返回列表</a> ]</div>
<form method="post" id="form2" name="form2">
<table width="95%" cellpadding=3 cellspacing=3>
<tr>
  <td colspan="3" rowspan="2" valign="top" class="tRight" ><table width="100%" border="0" cellspacing="0" cellpadding="0" id="tb1">
    <tr>
      <td width="22%" class="tRight" >物业名称：</td>
      <td width="70%" class="tLeft" ><input type="text" class="medium bLeft"  name="wymc" value="{$vo.wymc}" />
        [<a href="#" id="a_jz_d" f="jz_d" s="物业详细资料">详细</a>]</td>
      <td width="8%" class="tLeft">&nbsp;</td>
    </tr>
    <tr>
      <td class="tRight" >单元号：</td>
      <td class="tLeft" ><input type="text" name="dyh" class="medium bLeft" value="{$vo.dyh}" />
        </input></td>
      <td class="tLeft"></td>
    </tr>
    <tr>
      <td class="tRight" >总面积：</td>
      <td class="tLeft" ><input type="number" class="medium bLeft" name="zmj" value="{$vo.zmj}" title="总面积" />
        平方米</td>
      <td class="tLeft"></td>
    </tr>
    <tr>
      <td class="tRight" >建筑面积：</td>
      <td class="tLeft" ><input type="number" class="medium bLeft" name="jzmj" value="{$vo.jzmj}" title="建筑面积" />
        平方米</td>
      <td class="tLeft"></td>
    </tr>
    <tr>
      <td class="tRight" >&nbsp;</td>
      <td class="tLeft" ><input type="hidden" name="id" value="{$vo.id}" />
        <input type="hidden" name="ajax" value="1" />
        <input type="button" value="保 存" onclick="save()" class="small submit" /></td>
      <td class="tLeft"></td>
    </tr>
  </table></td>
  <td width="525" class="tLeft" >租赁人信息【<a href="#" id="a_addZlr">添加租赁人</a>】：</td>
  </tr>
<tr>
  <td align="left" valign="top" class="tRight" >
    <!--dddddddddddddddddddddddddddddddddddddddddddddddddddddddddd-->
    <!-- 列表显示区域  -->
    <div class="list" >
      <html:list id="checkList" title='fdafdsa' name="zl" style="list" action="true" datasource="list" show="id:编号,zlr:租赁人,yzj:月租金,zzj:总租金,zlrq1|toDate='Y-m-d':租赁起,zlrq2|toDate='Y-m-d':租赁止" actionlist="zledit:编辑,foreverdel:删除" />
      </div>
    <!-- 列表显示区域结束 --
    <!--dddddddddddddddddddddddddddddddddddddddddddddddddddddddddd-->
    </td>
</tr>
<tr>
  <td colspan="5" align="center"><!--<input type="reset" class="submit small" value="清 空" >--></td>
</tr>
</table>
</form>
</div>
</div>
<style>
.dlg{ height:520px; width:930px; top:2px; position:static; float:left;}
.dlg1{ height:500px; width:910px; float:left;}

#showZlr tr{ margin:10px; height:35px;}
#showZlr table{ margin:5px 10px;}
</style>
<div class="hide" style="height:100%" id="hideDiv">
    <div id="dlg_jz_d" class="dlg"><div id="div_jz_d" class="dlg1" f='jz_d'>{$vo.jz_d}</div></div> 
	
  <div id="tempDiv"></div>
    
  <div id="showZlr">
  <form id="zlrinfo" name="zlrinfo" method="post"><input type="hidden" name="id" id="id" value="" ><input type="hidden" name="wyid" id="wyid" value="{$Think.get.id}" >
    <table width="840">
        <tr>
          <td colspan="2" rowspan="2" valign="top" class="tRight"><table width="100%" border="0" cellspacing="0" cellpadding="2">
            <tr>
              <td class="tRight">租赁人：</td>
              <td align="left"><input type="text" name="zlr" id="zlr" class="medium bLeft" value="" /></td>
            </tr>
            <tr>
              <td class="tRight">身份证：</td>
              <td align="left"><input type="text" name="sfz" id="sfz" class="medium bLeft" value="" /></td>
            </tr>
            <tr>
              <td class="tRight">月租金：</td>
              <td align="left"><input type="number" name="yzj" id="yzj" class="medium bLeft" value="" /></td>
            </tr>
            <tr>
              <td class="tRight">总租金：</td>
              <td align="left"><input type="number" name="zzj" id="zzj" class="medium bLeft" value="" /></td>
            </tr>
            <tr>
              <td class="tRight">用途：</td>
              <td align="left"><input type="text" name="yt" id="yt" class="medium bLeft" value="" /></td>
            </tr>
            <tr>
              <td class="tRight">租赁始：</td>
              <td align="left"><input type="text" id="zlrq1" name="zlrq1" value="" />
                </input></td>
            </tr>
            <tr>
              <td class="tRight">租赁止：</td>
              <td align="left"><input type="text" id="zlrq2" name="zlrq2" value="" />
                </input></td>
            </tr>
          </table></td>
          <td width="29" rowspan="2">&nbsp;</td>
          <td width="502">租赁人详细信息[双击进入编辑状态]：</td>
    </tr>
        <tr>
          <td valign="top" id="dlg_zlr_d"><div id="div_zlr_d" style="height:300px; width:570px;"></div></td>
        </tr>
    </table>
    </form>
  </div>    
</div>

<include file="Public:footer" />
<script>
jQuery(function(){		
	$("#a_jz_d").click(function(){
		var ff = $(this).attr("f");//f用于表示操作的字段，
		var sf = $(this).attr("s");//s用于显示的标题
		$('#dlg_'+ff).unbind().dialog({
			onOpen:function(){
				$('html').addClass('hidescroll');},
			onClose:function(){
				$('html').removeClass('hidescroll');
				if(editor){ 
					$('#div_'+ff).html(editor.html());
					editor.remove();
					editor = null;
					window.location.reload();
				}
			},
			modal:true,title:sf+"使用详情查看修改对话框(双击进入编辑状态)",width:windowW,height:windowH,maximizable:true,resizable:true,
			buttons:[{
				text:'保存',iconCls:'icon-ok',
				handler:function(){
					if(!editor){ $('#dlg_'+ff).dialog('close');return;}
					var id 	= '{$Think.get.id}';
					$('#'+ff).html(editor.html());	
					var o		= {};//动态参数
					o[ff]		= editor.html();
					o['id']	= id;
					$.post("__URL__/update/",o,function(data){
						$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
						if(data.status){ $('#dlg_'+ff).dialog('close');}
					}//function
					,"json");//post	
				}
			},{
				text:'关闭',handler:function(){
					$('#dlg_'+ff).dialog('close');
				}
			}]
		});	
		//不足5个字符时直接显示编辑器
		if($('#div_'+ff).html().length<5){
			editor = showEditor(ff,0,495);
		}else{
			jQuery('#dlg_'+ff).one('dblclick',function(){
				editor = showEditor(ff,0,495);
			})
		}
	})//click
	
	//查找详情里面的图片，并加个链接a标签，为每个详情里的图片集生成一个'图'字，用于fancybox的图片集浏览	
	var aImg = $('#hideDiv img');
	var ff1 = "";//用于区分图片组的rel
	var temp= "";//用于临时记录上一次的rel，如果相同则不再添加节点
	aImg.each(function(i){
		ff1 = $(this).closest('.dlg1').attr('f');
		src = this.src;title = this.title;
		if(!$(this).parent().is('a')){
			if(temp!=ff1)
				$('#a_'+ff1).after("&nbsp;&nbsp;&nbsp;<a href='#' class='aGallay' title='"+ title +"' f='"+ff1+"'>图</a>");
			//$(this).wrap("<a href='"+ src +"' class='iGallay' rel='"+ ff1 +"' title='"+ title +"'></a>");
		}
		temp = ff1;
	})//each
	
	//给‘图‘a标签加个点击函数
	$('.aGallay').click(function(){
		f	= $(this).attr('f');
		$('#tempDiv').html($('#div_'+f).html());
		$('#tempDiv img').each(function(i){
			ff1 = $(this).closest('.dlg1').attr('f');
			src = this.src;title = this.title;
			if(!$(this).parent().is('a')){
				$(this).wrap("<a href='"+ src +"' class='iGallay' rel='"+ ff1 +"' title='"+ title +"'></a>");
			}
		})//each
		a = $('#tempDiv a').detach();	//将a标签从tempdiv中取出
		i = $('#tempDiv img').detach();	//将img标签从tempdiv中取出
		t	= $('#tempDiv').html();	//在tempdiv中只有text了！将t作为标题放入fancybox中
		$.fancybox( a ,{minWidth:'700px',autoSize:true,fitToView:true,openEffect:'fade',loop:false,
			helpers:{title:{type:'inside' }},
			afterLoad : function() {
					this.title = '[图片 ' + (this.index + 1) + ' of ' + this.group.length + ' ] ' +(this.title ? this.title: '') +'<br>'+t;
			}//function
		});	//fancybox
	})//click
	/////////////////////////////////////////////////////////////////////////////////////////
	//$("#form2").validator();
	$('#a_addZlr').click(function(){
		zledit(0);	
	})
})//jquery
		
function save(){
    var inputs = $("#form2 :input").validator({ lang: 'zh',position: 'right left',offset: [-12, 0],message: '<div><em/></div>' });//不用检测表单
    if(inputs.data("validator").checkValidity()){
		var queryString = $('#form2').serialize();
		$.post('__URL__/update/',queryString,function(data){
			$.messager.show({
				title:'提示信息',msg:data.info,timeout:2000,showType:'slide'
			});
		},'json')	
	}	
}
//zlid=0时为insert
function zledit(zlid){
	//赋值，
	ff='zlr_d';
	if(zlid>0){
	$.post("__APP__/Zl/myRead/",{id:zlid},function(d){
			$('#id').val(d.data['id']);
			$('#zlr').val(d.data['zlr']);
			$('#sfz').val(d.data['sfz']);
			$('#yzj').val(d.data['yzj']);
			$('#zzj').val(d.data['zzj']);
			$('#yt').val(d.data['yt']);
			//alert(d.data['zlrq1']);
			$('#zlrq1').val(getLocalTime(d.data['zlrq1'])).datebox(); 
			$('#zlrq2').val(getLocalTime(d.data['zlrq2'])).datebox();
			$('#div_zlr_d').html(d.data['zlr_d']);
			if($('#div_'+ff).html().length<5){
				editor = showEditor(ff,0,300);
			}else{
				jQuery('#dlg_'+ff).one('dblclick',function(){
					editor = showEditor(ff,0,300);
				})
			}
		}
	,"json");//post	
	}else{
		$('#id').val('');
		$('#zlrq1')	.datebox(); 
		$('#zlrq2')	.datebox(); 
		editor = showEditor(ff,0,300);
	}
	$('#showZlr').unbind().dialog({
		onOpen:function(){
			$('html').addClass('hidescroll');},
		onClose:function(){
			$('html').removeClass('hidescroll');
			if(editor){ 
				$('#'+ff).html(editor.html());
				editor.remove();
				editor = null;
				window.location.reload();
			}
		},
		modal:true,title:"查看修改租赁人详细情况对话框",width:900,height:'95%',maximizable:false,resizable:true,
		buttons:[{
			text:'保存',iconCls:'icon-ok',
			handler:function(){
				if(editor){
					$('#'+ff).val(editor.html());
				}	
				if(zlid>0){
					$.post("__APP__/Zl/update/",$('#zlrinfo').serialize(),function(data){
						$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
					}//function
					,"json");//post		
				}else{
					$.post("__APP__/Zl/insert/",$('#zlrinfo').serialize(),function(data){
						$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
					}//function
					,"json");//post	
				}//if zlid>0
			}
		},{
			text:'关闭',handler:function(){
				$('#showZlr').dialog('close');
			}
		}]
	});	
}
//永久删除///////////////
function foreverdel(id){
	var keyValue;
	if (id)
	{
	keyValue = id;
	}else {
	keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
	alert('请选择删除项！');
	return false;
	}
	if (window.confirm('确实要永久删除选择项吗？'))
	{
	$.post("__APP__/Zl/foreverdelete/","id="+keyValue+'&ajax=1',function(data){
			$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
			window.location.reload();
			//$("tr:contains('<td>"+id+"</td>')").remove();
		}//function
		,"json");//post	
	}
} 
</script>